package org.zfes.snowier.zbss.xzy.mo.dtos.jvm.detail;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
import java.util.Date;



/**
 * JVM相关信息
 * 
 */
public class SysJvmInfoDto implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//所属部署拓扑
	private String devicesn;
	//实例key
	private String inskey;
	//实例秒数
	private String insremark;
	
	
	private Byte st=1;
	private Date ti;
	private String message;

	/**
	 * 当前JVM占用的内存总数
	 */
	private Long total;

	/**
	 * JVM最大可用内存总数
	 */
	private Long max;

	/**
	 * JVM空闲内存
	 */
	private Long free;
	/**
	 * 已经使用内存
	 */
	private Long used;
	
	/**
	 * 内存使用率
	 */
	private Double usages;

	/**
	 * JDK版本
	 */
	private String version;

	/**
	 * JDK路径
	 */
	private String jvmhome;
	
	private String jvmname;

	private Date starttime;
	
	private String runtime;
	



	public Long getTotal() {
		return total;
	}

	public SysJvmInfoDto setTotal(Long total) {
		this.total = total;
		return this;
	}

	public Long getMax() {
		return max;
	}

	public SysJvmInfoDto setMax(Long max) {
		this.max = max;
		return this;
	}

	public Long getFree() {
		return free;
	}

	public SysJvmInfoDto setFree(Long free) {
		this.free = free;
		return this;
	}

	public Long getUsed() {
		return used;
	}

	public SysJvmInfoDto setUsed(Long used) {
		this.used = used;
		return this;
	}

	public Double getUsages() {
		return usages;
	}

	public SysJvmInfoDto setUsages(Double usages) {
		this.usages = usages;
		return this;
	}

	public String getVersion() {
		return version;
	}

	public SysJvmInfoDto setVersion(String version) {
		this.version = version;
		return this;
	}


	public String getJvmhome() {
		return jvmhome;
	}

	public SysJvmInfoDto setJvmhome(String jvmhome) {
		this.jvmhome = jvmhome;
		return this;
	}

	public String getJvmname() {
		return ManagementFactory.getRuntimeMXBean().getVmName();
	}

	public SysJvmInfoDto setJvmname(String jvmname) {
		this.jvmname = jvmname;
		return this;
	}


	public Date getStarttime() {
		return starttime;
	}

	public SysJvmInfoDto setStarttime(Date startTime) {
		this.starttime = startTime;
		return this;
	}

	public String getRuntime() {
		return runtime;
	}

	public SysJvmInfoDto setRuntime(String runTime) {
		this.runtime = runTime;
		return this;
	}

	public String getDevicesn() {
		return devicesn;
	}

	public SysJvmInfoDto setDevicesn(String devicesn) {
		this.devicesn = devicesn;
		return this;
	}

	public Byte getSt() {
		return st;
	}

	public SysJvmInfoDto setSt(Byte st) {
		this.st = st;
		return this;
	}

	public Date getTi() {
		return ti;
	}

	public SysJvmInfoDto setTi(Date ti) {
		this.ti = ti;
		return this;
	}

	public String getMessage() {
		return message;
	}

	public SysJvmInfoDto setMessage(String message) {
		this.message = message;
		return this;
	}

	public String getInskey() {
		return inskey;
	}

	public SysJvmInfoDto setInskey(String inskey) {
		this.inskey = inskey;
		return this;
	}

	public String getInsremark() {
		return insremark;
	}

	public SysJvmInfoDto setInsremark(String insremark) {
		this.insremark = insremark;
		return this;
	}

	@Override
	public String toString() {
		return "SysJvmInfoDto [devicesn=" + devicesn + ", inskey=" + inskey + ", insremark=" + insremark + ", st=" + st
				+ ", ti=" + ti + ", message=" + message + ", total=" + total + ", max=" + max + ", free=" + free
				+ ", used=" + used + ", usages=" + usages + ", version=" + version + ", jvmhome=" + jvmhome
				+ ", jvmname=" + jvmname + ", starttime=" + starttime + ", runtime=" + runtime + "]";
	}






//	public static String format(Date date, String pattern) {
//		if (date != null) {
//			SimpleDateFormat df = new SimpleDateFormat(pattern);
//			return df.format(date);
//		}
//		return null;
//	}

//	/**
//	 * 计算两个时间差
//	 */
//	public static String getDatePoor(Date endDate, Date nowDate) {
//		long nd = 1000 * 24 * 60 * 60;
//		long nh = 1000 * 60 * 60;
//		long nm = 1000 * 60;
//		// long ns = 1000;
//		// 获得两个时间的毫秒时间差异
//		long diff = endDate.getTime() - nowDate.getTime();
//		// 计算差多少天
//		long day = diff / nd;
//		// 计算差多少小时
//		long hour = diff % nd / nh;
//		// 计算差多少分钟
//		long min = diff % nd % nh / nm;
//		// 计算差多少秒//输出结果
//		// long sec = diff % nd % nh % nm / ns;
//		return day + "天" + hour + "小时" + min + "分钟";
//	}

//	/**
//	 * 获取服务器启动时间
//	 */
//	public static Date getServerStartDate() {
//		long time = ManagementFactory.getRuntimeMXBean().getStartTime();
//		return new Date(time);
//	}

	
	
	
//	public String getTotal() {
//		return String.valueOf(Arith.div(Double.valueOf(total), (1024 * 1024), 2));
//	}
//
//	public SysJvmInfoDto setTotal(String total) {
//		this.total = total;
//	}
//
//	public String getMax() {
//		return String.valueOf(Arith.div(Double.valueOf(max), (1024 * 1024), 2));
//	}
//
//	public SysJvmInfoDto setMax(String max) {
//		this.max = max;
//	}
//
//	public String getFree() {
//		return String.valueOf(Arith.div(Double.valueOf(free), (1024 * 1024), 2));
//	}
//
//	public SysJvmInfoDto setFree(String free) {
//		this.free = free;
//	}
//
//	public String getUsed() {
//		return String.valueOf(Arith.div(Double.valueOf(total) -Double.valueOf(free) , (1024 * 1024), 2));
//	}
//
//	public String getUsage() {
//		return String.valueOf(Arith.mul(Arith.div(Double.valueOf(total) - Double.valueOf(free),Double.valueOf(total) , 4), 100));
//	}
//
//	/**
//	 * 获取JDK名称
//	 */
//	public String getName() {
//		return ManagementFactory.getRuntimeMXBean().getVmName();
//	}
//
//	public String getVersion() {
//		return version;
//	}
//
//	public SysJvmInfoDto setVersion(String version) {
//		this.version = version;
//	}
//
//	public String getHome() {
//		return home;
//	}
//
//	public SysJvmInfoDto setHome(String home) {
//		this.home = home;
//	}
//
//	public SysJvmInfoDto setUsed(String used) {
//		this.used = used;
//	}
//
//	public String getStartTime() {
//
//		return format(getServerStartDate(),"yyyy-MM-dd HH:mm:ss");
//	}
//
//	public String getRunTime() {
//		return getDatePoor(new Date(),getServerStartDate());
//	}
//	
	
}
